import request from '@/utils/mgrAxios';
import { getToken } from '@/utils/auth';
import { Message } from 'ant-design-vue';

export function lingYanUpload(file, uuid) {
    var formData = new FormData();
    formData.append("file", file);
    formData.append("X-UUID", uuid);
    formData.append("X-TOKEN", getToken());
    formData.append("X-MIME-TYPE", "application/zip,application/octet-stream,application/x-rar,image/jpeg,image/gif,image/png,image/x-png,image/pjpeg,image/bmp,image/x-ms-bmp,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/x-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-powerpoint,text/plain,application/x-tar,video/mpeg,video/quicktime,video/x-msvideo,video/rm,video/x-ms-wmv,video/mp4,audio/AMR,audio/amr,application/vnd.rn-realmedia,application/vnd.rn-realmedia-vbr,audio/mp3,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/pdf,image/vnd.dwg");
    formData.append("X-UPLOAD-TYPE", "");
    return new Promise((resolve, reject) => {
        var host = process.env.NODE_ENV == "production" ? "" : "http://172.16.54.190:8082";
        request({
            url: host + "/oss/upload",
            method: 'post',
            data: formData,
            headers: {
                'X-TOKEN': getToken(),
                "X-UUID": uuid
            },
        }).then(resp => {
            resolve(resp);
            if (resp.status != 0) {
                Message.warning(resp.message);
            }
        });
    });
}